#ifndef CASH_H
#define CASH_h

#include <cmath>

class Cash
{
public:
    virtual double payCash(double price, int count) = 0;
};

class CashNormal : public Cash
{
public:
    double payCash(double price, int count)
    {
        return price * count;
    }
};

class CashDiscount : public Cash
{
public:
    CashDiscount(double discount)
    : discount(discount)
    {}

    double payCash(double price, int count)
    {
        return price * count * discount;
    }

private:
    double discount;
};

class CashRebate : public Cash
{
public:
    CashRebate(double condition, double rebate)
        : condition(condition)
        , rebate(rebate)
    {}

    double payCash(double price, int count)
    {
        int total = price * count;
        if (condition > 0 && total >= condition)
        {
            total -= floor(total / condition) * rebate;
        }

        return total;
    }

private:
    double condition;
    double rebate;
};

#endif